package examples 
{
	import flash.display.Sprite;
	import entities.PlatformBoy;
	import pure.engine.world.decorator.BackgroundMonitor;
	import pure.engine.world.decorator.MouseMonitor;
	import pure.engine.world.IMonitor;
	import pure.engine.world.WorldBody;

	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.net.*;
	import flash.utils.*;
	
	import pure.debug.*;
	import pure.engine.*;
	import pure.engine.world.*;
	import pure.engine.status.*;
	import pure.engine.status.motion.*;
	import pure.engine.world.WorldManager;
	import pure.ui.Button;
	import pure.utils.DesU;
	
	import sections.SectionData;
	
	/**
	 * ...
	 * @author Pure
	 */
	[SWF(width = '1150',height='650',frameRate = '60')]
public class SimpleDemo extends Sprite 
{
	
	public function SimpleDemo() 
	{
		this.addEventListener(Event.ADDED_TO_STAGE, init);
	}
	
	private function init(e:Event):void
	{
		this.removeEventListener(Event.ADDED_TO_STAGE, init);
		stage.quality = 'high';
		stage.align = 'TL';
		stage.scaleMode = 'noScale';
		
		// 启动
		Despair.startup(this.stage, false);

		// 注册片段
		Despair.registerSections(SectionData.data);

		// 注册实体
		Despair.registerEntities(PlatformBoy);

		// 注册世界Body
		var body:WorldBody = Despair.registerWorldBody('demo', 32, 1000, 600, 2);
		
		var monitor:IMonitor = body.getMonitor();
		
		body.setWorld(new SimpleWorld());
		monitor.show(this, 20, 20);
		
		monitor = new MouseMonitor(monitor);
		monitor = new BackgroundMonitor(monitor, 0x33ff00, 0.3, 1, 0, 0.9);
		
		this.addChild(new StatsKai());
		
		
		// 【UI】
		_initUI();
	}
	
	
	private function _initUI():void
	{
		var btn:Button = new Button(800, 50,new Point(80,30));
		addChild(btn);
		btn.setObserverClick(_onClick);
	}
	
	private function _onClick():void
	{
		//Despair.getWorldBody('demo').setWorld(new SimpleWorld());
		var body:WorldBody = Despair.getWorldBody('demo');
		body.interactive = !body.interactive;
	}
	
}

}